package main

import "gopkg.in/go-playground/validator.v9"

type RegisterReq struct {
	Username       string `json:"username"`
	PasswordNew    string `json:"password_new"`
	PasswordRepeat string `json:"password_repeat"`
	Email          string `json:"email"`
}

// register

type ReginterReq struct {
	Username string `validate:"gt=0"`
	PasswordNew string `validate:"gt=0"`
	PasswordRepeat string `validate:"eqfield=PasswordNew"`
	Email string `validate:"email"`
}

validate := validator.New()

func validate(req RegisterReq) error  {
	err := validate.Struct(req)
	if err != nil {
		doSomething()
		return err
	}

	return nil
}